************ democracy variables

****** Table_7_3: Lagged territorial size
use data/LandCover_GRID_CELL_v9_reduced.dta, clear
* polyarchy, 100-point scale
gen v2x_polyarchy_100 = (v2x_polyarchy / .924) * 100

* polyarchy, missing obs imputed
impute v2x_polyarchy lexical_index inc_chall_combined , gen(v2x_polyarchy_imp)
* 100-point scale
replace v2x_polyarchy_imp = v2x_polyarchy_imp * 100
gen v2x_polyarchy_imp_100 = (v2x_polyarchy_imp / 92.4) * 100
replace v2x_polyarchy_imp_100 = . if sovereign_Cojocaru ==.

* xtset is required for the panel analysis
* gen area_tril = area/1000000000000
* gen area_bil = area/1000000000
* gen area_mil = area/1000000

* gen AREA_GEO_1300_mil = AREA_GEO_1300/1000000
* gen AREA_GEO_1400_mil = AREA_GEO_1400/1000000
* gen AREA_GEO_1500_mil = AREA_GEO_1500/1000000
* gen AREA_GEO_1600_mil = AREA_GEO_1600/1000000
* gen AREA_GEO_1700_mil = AREA_GEO_1700/1000000
* gen AREA_GEO_1800_mil = AREA_GEO_1800/1000000
* gen AREA_GEO_1900_mil = AREA_GEO_1900/1000000
* gen AREA_GEO_2000_mil = AREA_GEO_2000/1000000

*1) 1300
qui reg v2x_polyarchy_imp_100 AREA_GEO_1300_mil i.year if year > 1949, vce(cluster gid)
qui local clusters=e(N_clust)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_7_3.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "Clusters", `clusters', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(AREA_GEO_1300_mil) replace
qui drop sample

*2) 1400
qui reg v2x_polyarchy_imp_100 AREA_GEO_1400_mil i.year if year > 1949, vce(cluster gid)
qui local clusters=e(N_clust)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_7_3.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "Clusters", `clusters', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(AREA_GEO_1400_mil) append
qui drop sample

*3) 1500
qui reg v2x_polyarchy_imp_100 AREA_GEO_1500_mil i.year if year > 1949, vce(cluster gid)
qui local clusters=e(N_clust)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_7_3.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "Clusters", `clusters', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(AREA_GEO_1500_mil) append
qui drop sample

*4) 1600
qui reg v2x_polyarchy_imp_100 AREA_GEO_1600_mil i.year if year > 1949, vce(cluster gid)
qui local clusters=e(N_clust)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_7_3.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "Clusters", `clusters', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(AREA_GEO_1600_mil) append
qui drop sample

*5) 1700
qui reg v2x_polyarchy_imp_100 AREA_GEO_1700_mil i.year if year > 1949, vce(cluster gid)
qui local clusters=e(N_clust)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_7_3.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "Clusters", `clusters', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(AREA_GEO_1700_mil) append
qui drop sample

*6) 200-year lag
qui reg v2x_polyarchy_imp_100 l200.area_tril i.year if year > 1949, vce(cluster gid)
qui local clusters=e(N_clust)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_7_3.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "Clusters", `clusters', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(l200.area_tril) append
qui drop sample

*7) both vars
qui reg v2x_polyarchy_imp_100 area_tril l200.area_tril i.year if year > 1949, vce(cluster gid)
qui local clusters=e(N_clust)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_7_3.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "Clusters", `clusters', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(l200.area_tril area_tril) append
qui drop sample

*8) + geography
qui reg v2x_polyarchy_imp_100 l200.area_tril area_tril predallports53_100km equator_distance i.e_regionpol4 i.year if year > 1949, vce(cluster gid)
qui local clusters=e(N_clust)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_7_3.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "Clusters", `clusters', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(l200.area_tril area_tril) append
qui drop sample
